Skip to content

Add regression test for PytestWarning: usefixtures() without arguments#803

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-pytest-warning-python-3-13
Closed

Add regression test for PytestWarning: usefixtures() without arguments#803
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-pytest-warning-python-3-13

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 5, 2026

pytest 9.x added a PytestWarning when usefixtures() is called with no arguments. This surfaced in pytest-bdd whenever a scenario function had no fixture arguments (e.g. test functions auto-generated by scenarios()), because pytest.mark.usefixtures(*func_args) was called unconditionally even with an empty func_args.

The fix (guarding the usefixtures call with if func_args:) was already present in the codebase (commit f955634, released in pytest-bdd 8.1.0). This PR adds a regression test to ensure this behaviour is maintained.

Changes

  • tests/feature/test_scenario.py: Add regression test test_no_usefixtures_warning_when_no_args that runs pytest with -W error::pytest.PytestWarning to confirm no spurious warning is emitted when using scenarios() with no-argument test functions.

Copilot AI changed the title [WIP] Fix PytestWarning for usefixtures in pytest-bdd Fix PytestWarning: usefixtures() without arguments when scenario has no fixture args Apr 5, 2026
Copilot AI requested a review from youtux April 5, 2026 23:16
@youtux
Copy link
Copy Markdown
Contributor

youtux commented Apr 6, 2026

@copilot You didn't fix anything

Copy link
Copy Markdown
Author

Copilot AI commented Apr 6, 2026

@copilot You didn't fix anything

You're right. My PR made no code changes - the if func_args: guard that prevents usefixtures() being called with empty args was already added in commit f955634 ("Avoid pytest.mark.usefixtures call without arguments") and released in pytest-bdd 8.1.0. My PR only added a regression test for that already-existing fix.

The issue reporter was using pytest_bdd-7.3.0 which predates the fix. Upgrading to 8.1.0+ resolves the warning.

If there's a remaining issue or a specific change you'd like me to make (e.g., a CHANGELOG entry, documentation update, or addressing a different edge case), please clarify and I'll address it.

Copilot AI changed the title Fix PytestWarning: usefixtures() without arguments when scenario has no fixture args Add regression test for PytestWarning: usefixtures() without arguments Apr 6, 2026
@youtux youtux closed this Apr 7, 2026
@youtux youtux deleted the copilot/fix-pytest-warning-python-3-13 branch April 7, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3.13 and pytest-bdd give "PytestWarning: usefixtures() in TESTNAME without arguments has no effect"

2 participants